/** 
 * 文件名：MaxTemperatureReducer.java 
 * 版本信息： 
 * 日期：Jun 3, 2010 
 * Copyright SafeCenterTeam@renren.com	2010 
 * 版权所有 
 * 
 */
package com.xiaonei.hadoop;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

/**
 * 项目名称：ice-test <br>
 * 类名称：MaxTemperatureReducer <br>
 * 类描述： <br>
 * 创建人：liushaohui <br>
 * 创建时间：Jun 3, 2010 4:19:36 PM <br>
 * 修改人：liushaohui <br>
 * 修改时间：Jun 3, 2010 4:19:36 PM <br>
 * 修改备注： <br>
 * 
 * @version
 */
public class MaxTemperatureReducer extends MapReduceBase implements
        Reducer<Text, IntWritable, Text, IntWritable> {

    @Override
    public void reduce(Text key, Iterator<IntWritable> values,
            OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
        int maxValue = Integer.MIN_VALUE;
        while (values.hasNext()) {
            maxValue = Math.max(maxValue, values.next().get());
        }
        output.collect(key, new IntWritable(maxValue));
    }
}
